package com.chb.controller;

import com.chb.annotation.LogAnnotation;
import com.chb.dao.DeptDao;
import com.chb.model.entity.Dept;
import com.chb.model.vo.Result;
import com.chb.service.DeptService;
import com.chb.service.OutLibrayService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ：张家琪
 * @date ：Created in 2023/10/9 17:50
 * @description：
 * @modified By：
 * @version:
 */
@RestController
@RequestMapping("/dept")
public class DeptController {
    @Autowired
    private DeptService deptService;

    /**
     * @param
     * @return
     * @create by: 张77
     * @description:查询所有部门
     * @create time: 2023/10/9 19:40
     */
    //查询所有部门
    @RequestMapping("/list")
    public Result list(Integer currentPage1, Integer pageSize1) {
        Result result = deptService.findAllDept(currentPage1, pageSize1);
        return result;
    }

    /**
     * @param
     * @return
     * @create by: 张77
     * @description:添加部门
     * @create time: 2023/10/9 19:42
     */
    @RequestMapping("/add")
    @ResponseBody
    @LogAnnotation(business_type = "增加部门")
    public Result add(@RequestBody Dept dept) {
        Result result = deptService.add(dept);
        return result;
    }

    /**
     * @param
     * @return
     * @create by: 张77
     * @description: 删除部门
     * @create time: 2023/10/9 20:45
     */
    @RequestMapping("/del")
    @LogAnnotation(business_type = "删除部门")
    public Result del(Integer deptid) {
        Result result = deptService.del(deptid);
        return result;
    }

    /**
     * @param
     * @return
     * @create by: 张77
     * @description: 修改部门信息
     * @create time: 2023/10/10 10:00
     */
    @RequestMapping("/updept")
    @ResponseBody
    @LogAnnotation(business_type = "删除部门")
    public Result updept(@RequestBody Dept dept) {
        Result result = deptService.updept(dept);
        return result;
    }

    /**
     * @param page 当前页数
     * @param pageSize 每页展示的页数
     * @param deptid 部门id
     * @return com.chb.model.vo.Result
     * @create by: 张77
     * @description: 获取部门下的员工信息
     * @create time: 2023/10/10 11:19
     */
    @RequestMapping("/selectStaffByDeptId")
    public Result selectStaffByDeptId(Integer page, Integer pageSize, Integer deptid) {

        return deptService.selectStaffByDeptId(page, pageSize, deptid);
    }
}
